import {ShaderMaterial} from "three";

/**
 * 基础贴图叠加材质
 */
export default class AddTextureBasicMaterial extends ShaderMaterial{
    constructor(baseTexture=null,addTexture=null,values={}){
        super(values);
        this.uniforms={
            baseTexture:{value:baseTexture},
            addTexture:{value:addTexture}
        };
        this.vertexShader=`
            varying vec2 vUv;
            void main() {
                vUv = uv;
                gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
            }
        `;
        this.fragmentShader=`
            uniform sampler2D baseTexture;
            uniform sampler2D addTexture;
            varying vec2 vUv;
            void main() {
                gl_FragColor = ( texture2D( baseTexture, vUv ) + vec4( 1.0 ) * texture2D( addTexture, vUv ) );
            }
        `;
    }
}